﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cactusMove : MonoBehaviour
{
    private float z = 10;

    // Start is called before the first frame update
    void Start()
    {
        this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, z);
    }

    // Update is called once per frame
    void Update()
    {
        this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, z);
        z -= 0.3f;
        
        if(z < -4){
            this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, z);
            z = Random.Range(45f, 50f); //Random.Range(10f, 15f)
        }
    }
}